home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / Technical.Notes / IIGS / TN.IIGS.076 < prev    next >
Encoding:
Text File  |  1991-11-15  |  15.2 KB  |  399 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. Apple IIgs
  8. #76:         Miscellaneous Resource Formats
  9.  
  10. Revised by:  Dave Lyons & Matt Deatherage                       December 1991
  11. Written by:  Matt Deatherage, C.K. Haun, Llew Roberts 
  12.              & Dave Lyons                                        January 1990
  13.  
  14. This Technical Note describes resource structure formats for previously- 
  15. unpublished types.
  16.  
  17. Changes since July 1991:  Added information on rTaggedStrings, rPatternList
  18. and rPrintRecord. Corrected typographical errors.
  19. _____________________________________________________________________________
  20.  
  21.  
  22. The format used to describe the resources is similar to that used in File 
  23. Type Notes, where the offsets, given in the form (+xxx), determine the offset 
  24. from the beginning of the resource.
  25.  
  26.  
  27. Sampled Sound Resource (Type: $8024, rSoundSample)
  28.  
  29. The following describes the Sampled Sound resource format.  It consists of a 
  30. ten-byte header followed by the sample data bytes.
  31.  
  32. Format       (+000)    Word    This must always be zero.
  33. Wave Size    (+002)    Word    Sample size in pages (256 bytes per page).  
  34.                                For example, an 8K sample takes 32 pages; a 
  35.                                128K sample requires $200 pages.
  36. Rel Pitch    (+004)    Word    The high byte of this word is a semitone
  37.                                value; the low byte is a fractional semitone.  
  38.                                These values are used to tune the sample to 
  39.                                correct pitch.  See HyperCard IIgs Technical 
  40.                                Note #3, Pitching Sampled Sound.
  41. Stereo       (+006)    Word    The output channel for this sound is in the 
  42.                                low nibble of this word.
  43. Sample rate  (+008)    Word    The sampling rate of the sound, in Hertz (Hz).
  44. Sound        (+010)    Bytes   The sampled sound data.  The bytes are all 
  45.                                8-bit samples.  The sample starts here and 
  46.                                continues until the end of the resource.
  47.  
  48. The resource compiler template follows:
  49.  
  50. #define rSoundSample    $8024
  51.  
  52. /*---------------------- rSoundSample --------------------*/
  53. type rSoundSample {
  54.     integer;        /* format */
  55.     integer;        /* wave size */
  56.     hex integer;        /* rel pitch */
  57.     integer;        /* stereo channel */
  58.     unsigned integer;    /* sample rate */
  59.     hex string;        /* raw 8 bit sound data */
  60. };
  61.  
  62.  
  63. Cursor Resource (Type: $8027, rCursor)
  64.  
  65. The following describes the Cursor resource format:
  66.  
  67. height       (+000)    Word    The height of the cursor, in pixels.
  68. width        (+002)    Word    The width of the cursor, in Words.
  69. image        (+004)    Bytes   The image of the cursor.  There are
  70.                                height*width Words in the cursor, or twice 
  71.                                that many Bytes.
  72.  
  73. We will call the first byte beyond the image offset "ei" for "end of image."
  74.  
  75. mask         (+ei)     Bytes   The mask of the cursor.  This is the same 
  76.                                size as the image.
  77.  
  78. We will call the first byte beyond the mask offset "em" for "end of mask."
  79.  
  80. hotSpotY     (+em)     Word    The cursor's Y "hot spot."
  81. hotSpotX     (+em+2)   Word    The cursor's X "hot spot."
  82. flags        (+em+4)   Flag Word
  83.                                Cursor flags:
  84.                                Bit 7: 1 = 640 Mode, 0 = 320 Mode
  85.                                All other bits are reserved and must be zero.
  86. reserved     (+em+6)   8 Bytes Reserved, must be zero.
  87.  
  88. The resource compiler template follows:
  89.  
  90. #define rCursor    $8027
  91.  
  92. /*---------------------- rCursor --------------------*/
  93. type rCursor {
  94.     height :
  95.         hex integer;            /* height */
  96.     width :
  97.         hex integer;            /* width in words */
  98.         hex string[2*$$Word(height)*$$Word(width)];    /* cursor image */
  99.         hex string[2*$$Word(height)*$$Word(width)];    /* cursor mask */
  100.         hex integer;            /* hotspot Y */
  101.         hex integer;            /* hotspot X */
  102.         hex integer;            /* flags */
  103.         hex longint = 0;        /* reserved */
  104.         hex longint = 0;        /* reserved */
  105.     };
  106. };
  107.  
  108. Following is a simple cursor example:
  109.  
  110. resource rCursor(1,fixed) {
  111.         5,     /* height */
  112.         2,     /* width */
  113.         $"ffff0000"
  114.         $"f00f0000"
  115.         $"f00f0000"
  116.         $"f00f0000"
  117.         $"ffff0000",
  118.  
  119.         $"ffff0000"
  120.         $"ffff0000"
  121.         $"ffff0000"
  122.         $"ffff0000"
  123.         $"ffff0000",
  124.  
  125.         2,     /* hotspot Y */
  126.         2,     /* hotspot X */
  127.         $80    /* 640 mode */
  128. };
  129.  
  130. Note that the resource is marked fixed so that its handle can be dereferenced 
  131. and passed to SetCursor.
  132.  
  133.  
  134. Version Resource (Type: $8029, rVersion)
  135.  
  136. Files may include a version resource with ID=1 for display by programs such 
  137. as the Finder.  All rVersion resource IDs other than 1 are reserved for 
  138. future definition.  The following describes the version resource format:
  139.  
  140. version      (+000)    Long    The application's version number, in Apple 
  141.                                IIgs Long Version format.  See Apple IIgs 
  142.                                Technical Note #100, VersionVille, for more 
  143.                                details.
  144. country      (+004)    Word    An international country version code.  
  145.                                Possible values are as follows:
  146.  
  147.                                verUS                 0
  148.                                verFrance             1
  149.                                verBritain            2
  150.                                verGermany            3
  151.                                verItaly              4
  152.                                verNetherlands        5
  153.                                verBelgiumLux         6
  154.                                verSweden             7
  155.                                verSpain              8
  156.                                verDenmark            9
  157.                                verPortugal          10
  158.                                verFrCanada          11
  159.                                verNorway            12
  160.                                verIsrael            13
  161.                                verJapan             14
  162.                                verAustralia         15
  163.                                verArabia            16
  164.                                verFinland           17
  165.                                verFrSwiss           18
  166.                                verGrSwiss           19
  167.                                verGreece            20
  168.                                verIceland           21
  169.                                verMalta             22
  170.                                verCyprus            23
  171.                                verTurkey            24
  172.                                verYugoslavia        25
  173.                                verIreland           50
  174.                                verKorea             51
  175.                                verChina             52
  176.                                verTaiwan            53
  177.                                verThailand          54
  178. name         (+006)    String  Pascal string containing the desired name.  
  179.                                May be the null string.
  180. moreInfo     (+xxx)    String  Additional information to be displayed, such 
  181.                                as a copyright notice.  May be the null 
  182.                                string.  Recommended maximum length is about 
  183.                                two lines of 35 characters each.  May contain 
  184.                                a carriage return (character $0D).
  185.  
  186. The resource compiler template follows:
  187.  
  188. #define rVersion    $8029
  189.  
  190. // Equates for the country code of an rVersion resource
  191.  
  192. #define Region \
  193.     verUS, verFrance, verBritain, verGermany,    \
  194.     verItaly, verNetherlands, verBelgiumLux,    \
  195.     verFrBelgiumLux = 6, verSweden, verSpain,    \
  196.     verDenmark, verPortugal, verFrCanada, verNorway,    \
  197.     verIsrael, verJapan, verAustralia, verArabia,    \
  198.     verArabic=16, verFinland, verFrSwiss, verGrSwiss,    \
  199.     verGreece, verIceland, verMalta, verCyprus,    \
  200.     verTurkey, verYugoslavia, verYugoCroatian = 25,    \
  201.     verIndia = 33, verIndiaHindi = 33, verPakistan,    \
  202.     verLithuania = 41, verPoland, verHungary,    \
  203.     verEstonia, verLatvia, verLapland, verFaeroeIsl,    \
  204.     verIran, verRussia, verIreland = 50, verKorea,    \
  205.     verChina, verTaiwan, verThailand    \
  206.  
  207. /*------------------- rVersion ------------------*/
  208. type rVersion {
  209.     ReverseBytes {
  210.         hex byte;                                // Major revision in BCD
  211.         hex bitstring[4];                        // Minor vevision in BCD
  212.         hex bitstring[4];                        // Bug version
  213.         hex byte    development = 0x20,          // Release stage        
  214.                     alpha = 0x40,
  215.                     beta = 0x60,
  216.                     final = 0x80, /* or */ release = 0xA0;
  217.         hex byte;                                 // Non-final release #
  218.     };
  219.     integer    Region;                            // Region code
  220.     pstring;                                      // Short version number
  221.     pstring;                                      // Long version number
  222. };
  223.  
  224. Following is a simple version example for "Super Graphics Destroyer", version 
  225. 2.0:
  226.  
  227. resource rVersion(1) {
  228.     { $02,$0,$0,release,$00 },                /* version 2.0 release */
  229.     verUS,                                    /* US version */
  230.     "Super Graphics Destroyer",               /* our app's name */
  231.     "(C) 1991 Pretty as a Picture, Inc."      /* the copyright notice */
  232. };
  233.  
  234. Note:    For compatibility with future system software, keep the name field 
  235.          identical across different versions of the same application, and 
  236.          make sure the version field increases on each later version released 
  237.          to your customers.  The moreInfo field is not critical; if it 
  238.          changes between versions, it's no big deal.
  239.  
  240.  
  241. Comment Resource (Type: $802A, rComment)
  242.  
  243. Files may include a comment resource with ID=1 for display by programs such 
  244. as the Finder.  All rComment resource IDs other than 1 are reserved for 
  245. future definition.  The following describes the comment resource format:
  246.  
  247. text         (+000)    Bytes   The comment.  This is unformatted, 8-bit text
  248.                                suitable for displaying by a desktop program.  
  249.                                No length limit is imposed by this resource 
  250.                                format, although a practical limit of a few 
  251.                                hundred characters is recommended.
  252.  
  253. The resource compiler template follows:
  254.  
  255. #define rComment    $802A
  256.  
  257. /*---------------------- rComment --------------------*/
  258. type rComment {
  259.     string;
  260. };
  261.  
  262.  
  263. Tagged Strings Resource (Type: $802E, rTaggedStrings)
  264.  
  265. A tagged strings resource lists pairs of Word values and Pascal strings.
  266.  
  267. count         (+000)    Word     Number of word/string pairs in this resource.
  268. firstWord     (+002)    Word     Word value of first pair.
  269. firstString   (+004)    String   Pascal string of first pair.
  270. secondWord    (+xxx)    Word     Word value of second pair.
  271. secondString  (+yyy)    String   Pascal string of second pair.
  272. ...            
  273.  
  274. The resource compiler template follows:
  275.  
  276. #define rTaggedStrings        $802E
  277.  
  278. /*------------------- rTaggedStrings --------------------*/
  279.  
  280. type rTaggedStrings {
  281.         integer = $$Countof(StringArray);
  282.         array StringArray {
  283.                 hex integer;        /* Key integer */
  284.                 pstring;            /* String */
  285.         };
  286. };
  287.  
  288. Following is a simple rTaggedStrings example:
  289.  
  290. resource rTaggedStrings(1) {{
  291.     $0050, "red",
  292.     $0033, "green",
  293.     $0100, "blue"
  294. }};
  295.  
  296.  
  297. Pattern List Resource (Type: $802F, rPatternList)
  298.  
  299. A pattern list resource contains zero of more 32-byte QuickDraw II 
  300. patterns. (This resource type exists for your convenience. The System 
  301. Software contains no direct support for resources of this type.)
  302.  
  303. firstPattern     (+000)    32 Bytes    First QuickDraw II pattern structure.
  304. secondPattern    (+032)    32 Bytes    Second QuickDraw II pattern structure.
  305. ...
  306.  
  307.  
  308. The resource compiler template follows:
  309.  
  310. #define rPatternList        $802F
  311.  
  312. /*-------------------- rPatternList ---------------------*/
  313.  
  314. type rPatternList {
  315.     array {
  316.         array[32] {
  317.             hex byte;
  318.         };
  319.     };
  320. };
  321.  
  322.  
  323. Rectangle List Resource (Type:  $C001, rRectList)
  324.  
  325. The rectangle list (type rRectList) is provided to allow an extensible, 
  326. easily modifiable collection of QuickDraw II rectangle structures.  This 
  327. capability can enhance a developer's ability to modify on-screen displays 
  328. without recompiling an entire application.  This resource also enables easier 
  329. cross-development and parallel development for the Apple IIgs and the 
  330. Macintosh.
  331.  
  332. The following describes the rectangle list resource format:
  333.  
  334. count        (+000)    Word    Number of rectangles in this resource.
  335. firstRectangle    
  336.              (+002)    8 Bytes First QuickDraw II rectangle structure.
  337.  
  338. ...                            Rectangles, eight bytes each.
  339.  
  340. lastRectangle (+002+(8*(count-1)))
  341.                        8 Bytes Last QuickDraw II rectangle structure.
  342.  
  343. The resource compiler template follows:
  344.  
  345. #define rRectList    $C001
  346. type rRectList {
  347.         integer = $$Countof(RectArray);
  348.         array RectArray {
  349.             Rect;
  350.             };
  351. };
  352.  
  353.  
  354. Print Record Resource (Type: $C002, rPrintRecord)
  355.  
  356. As a convenience for applications, a print record may be included as a 
  357. resource of type $C002 (rPrintRecord). If more than one of these 
  358. resources is present, the one to use as the document's primary print 
  359. record is the first one. You can get this resource's ID by calling 
  360. GetIndResource with type rPrintRecord and index 1. Storing the primary 
  361. print record with ID = 1 is a good way to start.
  362.  
  363. Since the print record is filled in and interpreted by the printer 
  364. driver, you can't always programmatically set options that are driver-
  365. specific. For example, although the ImageWriter driver stores the color-
  366. vs.-black and white option in one place, not all color printers will do 
  367. the same thing. If you want to use driver-specific options on many 
  368. printers, you can use those printer drivers to create print record that 
  369. reflect the options you want and store those records as resources. Then, 
  370. if you need a pre-initialized print record with the options you want, 
  371. you may already have one.
  372.  
  373.     print record    (+000)    160 Bytes    The print record.  The handle
  374.                                            to this resource is suitable for 
  375.                                            passing to any Print Manager call 
  376.                                            that requires a print record 
  377.                                            handle.
  378.  
  379. Since applications shouldn't create print records from scratch, but 
  380. rather allow printer drivers to fill them in with PrDefault and 
  381. PrVerify, the resource compiler template that follows only allocates 160 
  382. bytes for storage.
  383.  
  384. #define rPrintRecord    $C002
  385.  
  386. /*-------------------- rPrintRecord ------------------*/
  387. type rPrintRecord {
  388.     array[160] {
  389.         hex byte;
  390.     };
  391. };
  392.  
  393.  
  394. Further Reference
  395. _____________________________________________________________________________
  396.   o   Apple IIGS Toolbox Reference, Volumes 1-3
  397.   o   Apple IIgs Technical Note #100, VersionVille
  398.   o   HyperCard IIgs Technical Note #3, Pitching Sampled Sounds
  399.